load("@rules_motoko//motoko:defs.bzl", "motoko_binary")
load("@rules_rust//rust:defs.bzl", "rust_library")
load("//rs/tests:common.bzl", "IC_GATEWAY_RUNTIME_DEPS")
load("//rs/tests:system_tests.bzl", "system_test", "system_test_nns")

package(default_visibility = ["//rs:system-tests-pkg"])

# Just for testing if the Motoko code is correct.
motoko_binary(
    name = "counter_canister",
    entry = "canisters/counter.mo",
)

rust_library(
    name = "sdk-system-tests",
    testonly = True,
    srcs = glob(["src/**/*.rs"]),
    compile_data = [
        "canisters/counter.mo",
    ],
    crate_name = "sdk_system_tests",
    deps = [
        # Keep sorted.
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/types/types",
        "@crate_index//:backoff",
        "@crate_index//:candid",
        "@crate_index//:reqwest",
        "@crate_index//:serde_json",
        "@crate_index//:slog",
    ],
)

RUNTIME_DEPS = [
    "//:dfx",
]

system_test_nns(
    name = "dfx_smoke_test",
    env = {
        "DFX_PATH": "$(rootpath //:dfx)",
    },
    tags = [
        "long_test",  # since it takes longer than 5 minutes.
    ],
    runtime_deps = RUNTIME_DEPS + IC_GATEWAY_RUNTIME_DEPS + ["@nns_dapp_canister//file"],
    deps = [
        # Keep sorted.
        "sdk-system-tests",
        "//rs/registry/subnet_type",
        "//rs/tests/consensus/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/nns/nns_dapp",
        "@crate_index//:anyhow",
        "@crate_index//:slog",
    ],
)

system_test(
    name = "dfx_check_old_wallet_version_test",
    env = {
        "WALLET_CANISTER_0_7_2_WASM": "$(rootpath @wallet_canister_0.7.2//file)",
        "DFX_PATH": "$(rootpath //:dfx)",
    },
    runtime_deps = RUNTIME_DEPS + [
        "@wallet_canister_0.7.2//file",
    ],
    deps = [
        # Keep sorted.
        "sdk-system-tests",
        "//rs/registry/subnet_type",
        "//rs/tests/driver:ic-system-test-driver",
        "@crate_index//:anyhow",
        "@crate_index//:slog",
    ],
)
